package com.dt.common.response;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 响应数据
 *
 * @author <a href ='jiaoxuhui@dhcc.com.cn'>焦旭辉</a>
 * @date 2019/7/20
 * @since JDK 1.8
 */
@ApiModel(value = "响应数据")
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@NoArgsConstructor
public class ResponseData<T> implements Serializable {

    /**
     * 响应代码
     */
    @ApiModelProperty(value = "响应代码")
    private int code;

    /**
     * 响应消息
     */
    @ApiModelProperty(value = "响应消息")
    private String msg;

    /**
     * 响应数据
     */
    @ApiModelProperty(value = "响应数据")
    private T data;

    public ResponseData(ResponseCodeEnum responseCodeEnum, String msg) {
        this.code = responseCodeEnum.getCode();
        this.msg = msg;
    }

    public ResponseData(ResponseCodeEnum responseCodeEnum, String msg, T data) {
        this.code = responseCodeEnum.getCode();
        this.msg = msg;
        this.data = data;
    }

}

